package com.cam.framework.system.user.controller;

import com.cam.framework.system.menu.entity.SysMenu;
import com.cam.framework.system.menu.service.SysMenuService;
import com.cam.framework.system.user.service.SysUserService;
import com.cam.framework.utils.RestResult;
import com.cam.framework.utils.DictUtils;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Objects;

@RestController
@RequestMapping("/sys/user")
public class SysUserController {

    SysUserService sysUserService;

    SysMenuService sysMenuService;

    public SysUserController(SysUserService sysUserService, SysMenuService sysMenuService) {
        this.sysUserService = sysUserService;
        this.sysMenuService = sysMenuService;
    }

    @PostMapping("/login")
    public RestResult login(String username, String password) {
        return RestResult.success().put("token", "123456");
    }

    @GetMapping("/authorities")
    public RestResult authorities() {
        List<SysMenu> menuList = sysMenuService.list();
        HashMap<String, List<HashMap<String, Object>>> dictMap = DictUtils.getDictMap();
        return Objects.requireNonNull(RestResult.success().put("menuList", menuList)).put("dictMap", dictMap);
    }

}
